
main_init = function(mc){
 ep=0;sub_order=emission_order;loop_delay=-1; sqrt = Math.sqrt;
 o ={_visible:false}; atan2=Math.atan2; rnd=Math.random; floor=Math.floor;
 le=getTimer()/1000 + first_emission - min_between;
 se=stop_emission > 0 ? getTimer()/1000 + stop_emission : Infinity;
 if (zero_gravity){
  emit_particle = function(i){
   ep = sub_order==14 ? floor(rnd()*$sub_cnt) : (ep + 1) % $sub_cnt;
   var p = $smc[ep]; o.i = i;
   o._x = o.sx = one_origin ? 0 : p._x;
   o._y = o.sy = one_origin ? 0 : p._y;
   o.lt = min_lifetime+rnd()*(max_lifetime-min_lifetime);
   o.dx = o.sx+o.lt*(min_xvel+rnd()*(max_xvel-min_xvel))*mp_scale;
   o.dy = o.sy+o.lt*(min_yvel+rnd()*(max_yvel-min_yvel))*mp_scale;
   o._xscale = o._yscale = min_scale+rnd()*(max_scale-min_scale);
   if (particle_rotation) o._rotation = 90+atan2(o.dy-o.sy,o.dx-o.sx)*57.296;
   if (getTimer()/1000 - le < min_between){
    o.t = le + min_between;
   } else o.t = getTimer()/1000;
   le = o.t; min_between += between_change;
   if (min_between<0){ min_between = 0; between_change=0 }
   if (le < se){
    if (link_name.length > 0){
     mc.attachMovie(link_name,"p"+i,-i,o);
    } else {
     p.duplicateMovieClip("p"+i,-i,o);
    }
   } else {
    $mmc["p"+i].swapDepths($sub_cnt*10);
    $mmc["p"+i].removeMovieClip();
   }
  }
  o.onEnterFrame = function(){
   var tm = getTimer()/1000-this.t;
   if (tm > this.lt){
    emit_particle(this.i);
   } else if (tm >= 0) {
    var p = tm/this.lt; var rp = 1-p;
    this._x = this.sx*rp+this.dx*p;
    this._y = this.sy*rp+this.dy*p;
    this._alpha = nlf ? sqrt(rp)*100 : rp*100;
    this._visible = true;
   }
  }
 } else {
  emit_particle = function(i){
   ep = sub_order==14 ? floor(rnd()*$sub_cnt) : (ep + 1) % $sub_cnt;
   var p = $smc[ep]; o.i = i;
   o.px = o._x = o.sx = one_origin ? 0 : p._x;
   o.py = o._y = o.sy = one_origin ? 0 : p._y;
   o.xv = min_xvel+rnd()*(max_xvel-min_xvel);
   o.yv = min_yvel+rnd()*(max_yvel-min_yvel);
   o._xscale = o._yscale = min_scale+rnd()*(max_scale-min_scale);
   o.lt = min_lifetime+rnd()*(max_lifetime-min_lifetime);
   if (getTimer()/1000 - le < min_between){
    o.t = le + min_between;
   } else o.t = getTimer()/1000;
   le = o.t; min_between += between_change;
   if (min_between<0){ min_between = 0; between_change=0 }
   if (le < se){
    if (link_name.length > 0){
     mc.attachMovie(link_name,"p"+i,-i,o);
    } else {
     p.duplicateMovieClip("p"+i,-i,o);
    }
   } else {
    $mmc["p"+i].swapDepths($sub_cnt*10);
    $mmc["p"+i].removeMovieClip();
   }
  }
  if (particle_rotation){
   o.onEnterFrame = function(){
    var tm = getTimer()/1000-this.t;
    if (tm > this.lt){
     emit_particle(this.i);
    } else if (tm >= 0) {
     var px = this._x; var py = this._y;
     this._x = this.sx + this.xv * tm * mp_scale;
     this._y = this.sy + this.yv * tm * mp_scale + 4.9 * tm * tm * mp_scale;
     this._rotation = 90+atan2(this._y-py,this._x-px)*57.296;
     this._alpha = nlf ? 100*sqrt(1-tm/this.lt) : 100-100*tm/this.lt;
     this._visible = true;
    }
   }
  } else {
   o.onEnterFrame = function(){
    var tm = getTimer()/1000-this.t;
    if (tm > this.lt){
     emit_particle(this.i);
    } else if (tm >= 0) {
     this._x = this.sx + this.xv * tm * mp_scale;
     this._y = this.sy + this.yv * tm * mp_scale + 4.9 * tm * tm * mp_scale;
     this._alpha = nlf ? 100*sqrt(1-tm/this.lt) : 100-100*tm/this.lt;
     this._visible = true;
    }
   }
  }
 }
}

// main_effect function

main_effect = function(mc,frame){
 for(i=0;i<max_particles;i++) emit_particle(i);
 end_effect = true;
}

// sub_init function

sub_init = function(mc){
 if (hide_original) mc._alpha = 0;
}

// sub_effect function

sub_effect = function(mc,frame){
}
